<html>
<head>
<title>TRANG CHỦ</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
<!--
.style3 {
	color: #000000;
	font-weight: bold;
}
.style4 {
	font-size: 16px;
	font-style: italic;
	font-weight: bold;
	color: #FF0000;
}
.style5 {font-weight: bold; color: #FF0000; font-size: 16px;}
-->
</style>
<?php
	//Ket noi CSDL
	$db = mysql_connect("localhost", "root", "");
	if(!$db)
	{
		echo "Khong the ket noi CSDL!!!";
		exit;
	}
	mysql_select_db("quangcaosp");
	mysql_query("SET character_set_results=utf8", $db);

?>
</head>
<body marginwidth="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
  <tr>
    <td width="100%" height="772"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
        <tr>
          <td width="50%"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
              <tr>
                <td background="images/rez_top.jpg" style="background-repeat:repeat-x; width:50%; height:142px;"></td>
              </tr>
              <tr>
                <td background="images/rez_bgr.jpg" style="background-repeat:repeat; width:50%; height:100%;"></td>
              </tr>
              <tr>
                <td background="images/rez_bot.jpg" style="background-repeat:repeat-x; width:50%; height:87px;"></td>
              </tr>
            </table></td>
          <td width="766" bgcolor="#FFFFFF"><table border="0" cellpadding="0" cellspacing="0" width="766" height="100%">
              <!--flash-->
              <tr>
                <td width="766" height="142" background="images/rez_top.jpg" style="background-repeat:repeat-x; width:766px; height:142px;"><table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="766" height="89"><table border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td><a href="#"><img src="images/slogan.jpg" width="208" height="46" border="0" style="margin:28px 0 0 24px;"></a></td>
                            <td width="262"><p style="margin-top:47px;"><img src="images/txt_best.jpg"></p></td>
                            <td><img src="images/aa2.jpg" style="margin-right:9px;"></td>
                            <td width="159"><table border="0" cellpadding="0" cellspacing="0" style="margin-top:14px;">
                                <tr>
                                  <td><a href="#"><img src="images/b1.jpg" width="21" height="15" border="0"></a><a href="#"><img src="images/b2.jpg" width="21" height="15" border="0" style="margin:0 7px 0 4px;"></a></td>
                                  <td><select style="width:83px; height:17px; font-weight:900; font-size:10px;">
                                      <option>VN Dong</option>
                                    </select></td>
                                </tr>
                                <tr>
                                  <td><img src="images/spacer.gif" width="1" height="6"></td>
                                </tr>
                                <tr>
                                  <td colspan="10"><a href="#"><img src="images/x1.jpg" width="136" height="39" border="0"></a></td>
                                </tr>
                              </table></td>
                            <td><p align="center"><a href="index.php">
                                <input type="image" src="images/p1.jpg">
                                </a>
                                <input type="image" src="images/p2.jpg">
                                <a href="mailto:">
                                <input type="image" src="images/p3.jpg">
                                </a></p>
                              <p>&nbsp;</p>
                              <a title='Facebook quảng cáo sản phẩm' href='http://www.facebook.com/sanpham360.vn' target='_blank'><img alt='' src="images/imgFollowMeFacebook.png" class='img_absmiddle' width="90" height="15"/></a>
				<a title='Twitter quảng cáo sản phẩm' href='http://www.twitter.com/quangcaosanpham' target='_blank'><img alt='' src="images/imgFollowMeTwitter.png" class='img_absmiddle' width="90" height="15"/></a>
				<a title='Youtube quảng cáo sản phẩm' href='http://www.youtube.com/quangcaosanpham' target='_blank'><img alt='' src="images/imgFollowMeYouTube.png" class='img_absmiddle' width="90" height="15"/></a>
				<a title='Myspace quảng cáo sản phẩm' href='http://www.myspace.com/quangcaosanpham' target='_blank'><img alt='' src="images/imgFollowMeMySpace.png" class='img_absmiddle' width="90" height="15"/></a></td>
                          </tr>
                        </table></td>
                    </tr>
                    <tr>
                      <td height="53" width="766"><table border="0" cellpadding="0" cellspacing="0" width="766">
                          <tr>
                            <td><img src="images/spacer.gif" width="1" height="17"></td>
                            <td width="204"><table border="0" cellpadding="0" cellspacing="0" width="204">
                                <tr>
                                  <form action="index.php" name="form2" id="form2">
                                    <td height="21" align="center" valign="middle"><a href="dangnhap.php">
                                      <label> </label>
                                      </a>
                                      <label>
                                      <center>
                                      <p align="center">&nbsp;</p>
                        <?php
						session_start();
						if(isset($_SESSION['email']))
						{
							$email= $_SESSION['email'];
							$sql ="SELECT * FROM THANHVIEN WHERE email = '$email'";
							$result = mysql_query($sql, $db);
							if(mysql_num_rows($result)<>0)
							{
								while($row = mysql_fetch_row($result))
								{
									$hoten = $row[2];
									echo "<p align='center' class='style1'><a href='thong_tin_tai_khoan.php'>Xin chào $hoten</a>&nbsp;<br>
                                      <label class='style1'><a href='dangxuat.php'>Đăng Xuất</a></label>";
								}
							}
						}
						else
						{
							echo "<p align='center' class='style1'><a href='dangnhap.php'>Đăng nhập</a>										  													&nbsp; 
                                      <label class='style1'><a href='dangki.php'>Đăng kí</a></label>";
											}
						 ?>
                                    </td>
                                  </form>
                                </tr>
                                <tr>
                                  <td width="204" height="32" bgcolor="#FFFFFF"><p style="margin:16px 0 0 15px; color:#696969;"><strong>Tìm kiếm trên web:</strong></p></td>
                                </tr>
                              </table></td>
                            <td><img src="images/aa11.jpg"></td>
                            <td width="492"><table border="0" cellpadding="0" cellspacing="0" width="492">
                                <tr>
                                  <td class="m1" onMouseOver="this.className='m1m'" onMouseOut="this.className='m1'"><a href="index.php"><img src="images/spacer.gif" width="52" height="53" border="0"></a></td>
                                  <td class="m2" onMouseOver="this.className='m2m'" onMouseOut="this.className='m2'"><a href="san_pham_hot.php"><img src="images/spacer.gif" width="121" height="53" border="0"></a></td>
                                  <td class="m3" onMouseOver="this.className='m3m'" onMouseOut="this.className='m3'"><a href="thong_tin_tai_khoan.php"><img src="images/spacer.gif" width="104" height="53" border="0"></a></td>
                                  <td class="m4" onMouseOver="this.className='m4m'" onMouseOut="this.className='m4'"><a href="gianhang.php"><img src="images/spacer.gif" width="122" height="53" border="0"></a></td>
                                  <td class="m5" onMouseOver="this.className='m5m'" onMouseOut="this.className='m5'"><a href="lienhe.php"><img src="images/spacer.gif" width="126" height="53" border="0"></a></td>
                                </tr>
                              </table></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
              <!--footer-->
              <tr>
                <td height="529"><table border="0" cellpadding="0" cellspacing="0" height="100%">
                    <tr>
                      <td width="246"><table border="0" cellpadding="0" cellspacing="0" width="246" height="100%">
                          <tr>
                            <td width="231" height="58"><form action="tim_kiem_san_pham.php" method="post">
                                <table border="0" cellpadding="0" cellspacing="0" style="margin-left:15px;">
                                  <tr>
                                    <td><input name="tim_kiem" type="text" id="tim_kiem" style="width:142px; height:19px; border:1px solid #767676;" value="<?php echo $_POST["tim_kiem"];?>"></td>
                                    <td><?php
										$tim_kiem = $_POST["tim_kiem"];
										echo "<a href='tim_kiem_san_pham.php?tim_kiem=".$tim_kiem."'>";
									
                                     	echo "<input type='image' style='margin-left:2px;' src='images/kn_go.jpg'>";
                                      echo "</a> </td>";
									  ?>
                                  </tr>
                                  <tr>
                                    <td><img src="images/spacer.gif" width="1" height="5"></td>
                                  </tr>
                                  <tr>
                                    <td colspan="10"><a href="#" class="ins" style="color:#FF9536; font-size:10px;">consetetur</a></td>
                                  </tr>
                                </table>
                              </form></td>
                          </tr>
                          <tr>
                            <td width="246" height="100%"><table border="0" cellpadding="0" cellspacing="0" style="margin-left:15px;" width="216" height="100%">
                                <tr>
                                  <td><img src="images/txt_shop.jpg"></td>
                                </tr>
                                <tr>
                                  <td width="216" height="100%" bgcolor="#F6F6F6"><table border="0" cellpadding="0" cellspacing="0" style="margin:16px 0 0 20px;">
                                      <tr>
                                        <td><?php
									  $result = mysql_query("SELECT * FROM loaisp");	
										if(mysql_num_rows($result) <> 0)
										{
											  
											  while ($row = mysql_fetch_row($result))
											  {
												 
												$MaLoaiSP = $row[0];
												$TenLoaiSP = $row[1];
												  echo "<tr>";
													echo " <td><p><img src='images/ch_12.jpg' style='margin-right:17px;'><a href='#' class='deep' style='font-weight:900;'>$TenLoaiSP</a></p>";
                                       echo "<p style='margin:3px 0 3px 14px;'><img src='images/dot_left.jpg'></p>";
													
												  echo "</tr>";
												 
											  }
										
										}
									?>
                                          <p style="margin:3px 0 3px 14px;"><img src="images/dot_left.jpg"></p>
                                          <p style="margin:3px 0 3px 14px;"><img src="images/dot_left.jpg"></p></td>
                                      </tr>
                                    </table></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr>
                            <td><a href="#"><img src="images/x111.jpg" width="246" height="150" border="0"></a></td>
                          </tr>
                        </table></td>
                      <td background="images/bgr_bot111.jpg" style="background-repeat:no-repeat; width:520px; height:100%; background-position:bottom;"><table border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td width="517">
							  <p>
							    <?php
session_start();
/*if (!isset($_SESSION['level']) || $_SESSION['level'] == ''){
	echo "<script type='text/javascript'>window.location='../index.php';</script>"; 
}*/
include_once('controller/db.php');
$db = new DB;
$result = $db->execute("select * from gianhang");

//$result = $db->execute("select * from gianpham where MaGianHang = '$MaGianHang' ");

  // Các giá trị dược lưu trong biến $_POST
  // Kiểm tra nếu được post
  if($_POST) {
      // Đưa dữ liệu vào các biến
		$TenGianHang = $_POST['TenGianHang'];
		$MaTV = $_POST['MaTV'];
		$MaSP = $_POST['MaSP'];
		$NgayDangKy = $_POST['NgayDangKy'];	
      // Phần xử lý của các bạn..
        $result2 = $db->execute("INSERT INTO gianhang (TenGianHang,MaTV,MaSP,NgayDangKy) VALUES ('$TenGianHang', '$MaTV', '$MaSP', '$NgayDangKy')"); 

		if(!$result2)
			echo "<script type='text/javascript'>alert('>>> ( Failed !!! ) <<<'); window.location='quan_ly_gian_hang.php';</script>"; 
		echo "<script type='text/javascript'>window.location='quan_ly_gian_hang.php'</script>";
 }

?>
                              <table width="512" id="hor-minimalist-b">
                                <tr>
                                  <th width="234" height="43" scope="col">Tên Gian Hàng</th>
                                  <th width="38" scope="col">Mã Thành Viên</th>
                                  <th width="32" scope="col">Mã Sản Phẩm</th>
                                  <th width="111" scope="col">Ngày Đăng Ký</th>
                                  <th scope="col" colspan="2"><a class='icon' id="nv_them">Sửa/Xóa</a></th>
                                </tr>
                                <tbody>
                                  <?php	while ($row = mysql_fetch_assoc($result)) {	?>
                                  <tr>
                                    <td>                                      <div align="left"><?php echo $row['TenGianHang'] ?>
                                      </div></td>
                                    <td><center>
                                      <?php echo $row['MaTV'] ?>
                                    </center></td>
                                    <td><center>
                                      <?php echo $row['MaSP'] ?>
                                    </center></td>
                                    <td>                                      <div align="left"><?php echo $row['NgayDangKy'] ?>
                                      </div></td>
                                    <td width="29"><a class='icon' href='<?php echo "edit_gianhang.php?id={$row['MaGianHang']}" ?>'><span class='edit'>edit</span></a></td>
                                    <td width="40"><a class='icon' href='<?php echo "del_gianhang.php?id={$row['MaGianHang']}" ?>' onClick="return confirm('Bạn có muốn xóa không?')"><span class='delete'>delete</span></a></td>
                                  </tr>
                                  <?php } ?>
                                </tbody>
                              </table>
                              </p>
<p>&nbsp;</p>  
<div class="box" id="box_nv">
	<a class="boxclose" id="boxclose"></a>
	</br>
							  <form id="gianhang_add" action="quan_ly_gian_hang.php" method="post">
                                <fieldset>
                                  <legend class="style5">THÊM GIAN HÀNG </legend>
                                  <p class="style4">&nbsp;</p>
                                  <table width="507" border="1" align="center" bgcolor="#00CCFF">
                                  <tr>
                                    <td width="114" class="style3">Tên gian hàng </td>
                                    <td width="377"><input type="text" name="TenGianHang" id="TenGianHang" class="required" /></td>
                                  </tr>
                                  <tr>
                                    <td><label for="name" class="style3">Mã thành viên </label></td>
                                    <td><input type="text" name="MaTV" id="MaTV" class="required" /></td>
                                  </tr>
                                  <tr>
                                    <td class="style3">Mã sản phẩm </td>
                                    <td><input type="text" name="MaSP" id="MaSP" class="required" /></td>
                                  </tr>
                                  <tr>
                                    <td><label for="name" class="style3">Ngày đăng kí </label></td>
                                    <td><label>
                                      <input type="text" name="NgayDangKy" id="NgayDangKy" class="required" />
                                    </label></td>
                                  </tr>
                                  <tr>
                                    <td colspan="2"><center>
                                        <span class="submit">
                                        <input name="submit" type="submit" id="submit" value="Đồng ý" />
                                        </span>
                                    </center></td>
                                  </tr>
                                </table>
                                  <p>&nbsp;</p>
                                  <p>
                                  <label for="name"></label>
                                </p>
                                  <p>
                                    <label for="name"></label>
                                </p>
                                  <p>
                                    <label for="name"></label>
                                </p>
                                  <p>
                                    <label for="name"></label>
                                </p>
                                  <p>
                                    <label for="name"></label>
                                </p>
                                  <p>
                                    <label for="name"></label>
                                </p>
                                  <p>
                                    <label for="name"></label>
                                </p>
                                  <p>
                                    <label for="name" class="l2"></label>
                                </p>
                                  <p>
                                    <label for="name" class="l2"></label>
                                </p>
                                  <p>
                                    <label for="name" class="l2"></label>
                                </p>
                                  <p class="submit">&nbsp;</p>
                                </fieldset>
				            </form>		
							</div>
<script type="text/javascript">
    $(function() {
        $('#sp_them').click(function(){
            $('#overlay').fadeIn('fast',function(){
                $('#box_nv').animate({'top':'50px'},100);
            });
        });
        $('#boxclose,#overlay').click(function(){
            $('#box_nv').animate({'top':'-800px'},500,function(){
                $('#overlay').fadeOut('fast');
            });
        });
    });
$(document).ready(function(){
	// Validate form
	$("#add_gianhang").validate({
		errorElement: "span", // Định dạng cho thẻ HTML hiện thông báo lỗi
	});
});
</script>
				      <p>&nbsp;  </p></td>
                            <td width="10">&nbsp;</td>
                          </tr>
                        </table></td>
                    </tr>
					
                  </table></td>
              </tr>
			  
              <tr>
                <td width="766"><table border="0" cellpadding="0" cellspacing="0" width="766">		
					
                    <tr>
                      <td><img src="images/w1.jpg"></td>
					  
					  
                        <td background="images/w3_bgr.jpg" style="background-repeat:repeat-x; width:711px; height:101px;"><p style="margin:37px 0 0 131px; " class="end"><strong class="end" style="text-decoration:underline;"><a href="index.php">Home</a></strong> &nbsp; |&nbsp; <a href="san_pham_hot.php"> Sản phẩm hot</a> &nbsp; |&nbsp; <a href="quan_ly_san_pham.php">Quản lý sản phẩm </a> |&nbsp; <a href="quan_ly_gian_hang.php">Quản lý gian hàng </a> &nbsp;|&nbsp; <a href="lienhe.php">Liên hệ</a>|&nbsp; <a href="lienketvang.php">Liên kết vàng</a> |&nbsp; <a href="top_estore.php">Top Estore</a></p>
					  
                        <p style="margin:35px 0 0 261px;" class="end1">Bản quyền thuộc về &copy; 2012.WeAreOne. All rights reserved</p>
						
						</td>
						 
                      <td><img src="images/w2.jpg"></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
          <td width="50%"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
              <tr>
                <td background="images/rez_bgr.jpg" style="background-repeat:repeat; width:50%; height:100%;"></td>
              </tr>
              <tr>
                <td background="images/rez_bot.jpg" style="background-repeat:repeat-x; width:50%; height:87px;"></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
